/*
 * Class38 - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
public class Class38 {
	private static byte aByte664 = 6;
	private int anInt665 = -573;
	private int anInt666 = -252;
	private static boolean aBoolean667 = true;
	private static Class38[] aClass38Array668 = new Class38[5000];
	public static int[] anIntArray669 = new int[5000];
	private static byte[] aByteArray670;
	private static Packet aPacket_671;
	private Class11[] aClass11Array672 = new Class11[10];
	private int anInt673;
	private int anInt674;

	private Class38(int i) {
		if (i >= 0) {
			throw new NullPointerException();
		}
	}

	public static final void method376(Packet packet, int i) {
		if (i == 36135) {
			Class38.aByteArray670 = new byte[441000];
			Class38.aPacket_671 = new Packet(Class38.aByteArray670);
			Class11.method190();
			for (;;) {
				int i_0_ = packet.getUShort();
				if (i_0_ == 65535) {
					break;
				}
				Class38.aClass38Array668[i_0_] = new Class38(-524);
				Class38.aClass38Array668[i_0_].method378(Class38.aByte664, packet);
				Class38.anIntArray669[i_0_] = Class38.aClass38Array668[i_0_].method379(0);
			}
		}
	}

	public static final Packet method377(int i, byte i_1_, int i_2_) {
		if (i_1_ != 6) {
			Class38.aBoolean667 = !Class38.aBoolean667;
		}
		if (Class38.aClass38Array668[i_2_] != null) {
			Class38 class38 = Class38.aClass38Array668[i_2_];
			return class38.method380(-573, i);
		}
		return null;
	}

	private final void method378(byte i, Packet packet) {
		for (int i_3_ = 0; i_3_ < 10; i_3_++) {
			int i_4_ = packet.getUByte();
			if (i_4_ != 0) {
				packet.offset--;
				aClass11Array672[i_3_] = new Class11();
				aClass11Array672[i_3_].method193(Class38.aByte664, packet);
			}
		}
		anInt673 = packet.getUShort();
		anInt674 = packet.getUShort();
		if (i == 6) {
		} else {
			anInt666 = 64;
		}
	}

	private final int method379(int i) {
		int i_5_ = 9999999;
		for (int i_6_ = 0; i_6_ < 10; i_6_++) {
			if (aClass11Array672[i_6_] != null && (aClass11Array672[i_6_]).anInt199 / 20 < i_5_) {
				i_5_ = (aClass11Array672[i_6_]).anInt199 / 20;
			}
		}
		if (anInt673 < anInt674 && anInt673 / 20 < i_5_) {
			i_5_ = anInt673 / 20;
		}
		if (i_5_ == 9999999 || i_5_ == 0) {
			return 0;
		}
		for (int i_7_ = 0; i_7_ < 10; i_7_++) {
			if (aClass11Array672[i_7_] != null) {
				(aClass11Array672[i_7_]).anInt199 -= i_5_ * 20;
			}
		}
		if (i != 0) {
			Class38.aBoolean667 = !Class38.aBoolean667;
		}
		if (anInt673 < anInt674) {
			anInt673 -= i_5_ * 20;
			anInt674 -= i_5_ * 20;
		}
		return i_5_;
	}

	private final Packet method380(int i, int i_8_) {
		int i_9_ = method381(i_8_);
		Class38.aPacket_671.offset = 0;
		Class38.aPacket_671.putInt(1380533830);
		Class38.aPacket_671.putLEInt(i_9_ + 36);
		Class38.aPacket_671.putInt(1463899717);
		Class38.aPacket_671.putInt(1718449184);
		if (i >= 0) {
			throw new NullPointerException();
		}
		Class38.aPacket_671.putLEInt(16);
		Class38.aPacket_671.putLEShort(1);
		Class38.aPacket_671.putLEShort(1);
		Class38.aPacket_671.putLEInt(22050);
		Class38.aPacket_671.putLEInt(22050);
		Class38.aPacket_671.putLEShort(1);
		Class38.aPacket_671.putLEShort(8);
		Class38.aPacket_671.putInt(1684108385);
		Class38.aPacket_671.putLEInt(i_9_);
		Class38.aPacket_671.offset += i_9_;
		return Class38.aPacket_671;
	}

	private final int method381(int i) {
		int i_10_ = 0;
		for (int i_11_ = 0; i_11_ < 10; i_11_++) {
			if (aClass11Array672[i_11_] != null
				&& ((aClass11Array672[i_11_]).anInt198 + (aClass11Array672[i_11_]).anInt199) > i_10_) {
				i_10_ = ((aClass11Array672[i_11_]).anInt198 + (aClass11Array672[i_11_]).anInt199);
			}
		}
		if (i_10_ == 0) {
			return 0;
		}
		int i_12_ = i_10_ * 22050 / 1000;
		int i_13_ = anInt673 * 22050 / 1000;
		int i_14_ = anInt674 * 22050 / 1000;
		if (i_13_ < 0 || i_13_ > i_12_ || i_14_ < 0 || i_14_ > i_12_ || i_13_ >= i_14_) {
			i = 0;
		}
		int i_15_ = i_12_ + (i_14_ - i_13_) * (i - 1);
		for (int i_16_ = 44; i_16_ < i_15_ + 44; i_16_++) {
			Class38.aByteArray670[i_16_] = (byte) -128;
		}
		for (int i_17_ = 0; i_17_ < 10; i_17_++) {
			if (aClass11Array672[i_17_] != null) {
				int i_18_ = ((aClass11Array672[i_17_]).anInt198 * 22050 / 1000);
				int i_19_ = ((aClass11Array672[i_17_]).anInt199 * 22050 / 1000);
				int[] is = (aClass11Array672[i_17_].method191(i_18_,
					(aClass11Array672[i_17_]).anInt198));
				for (int i_20_ = 0; i_20_ < i_18_; i_20_++) {
					int i_21_ = ((Class38.aByteArray670[i_20_ + i_19_ + 44] & 0xff) + (is[i_20_] >> 8));
					if ((i_21_ & ~0xff) != 0) {
						i_21_ = i_21_ >> 31 ^ 0xffffffff;
					}
					Class38.aByteArray670[i_20_ + i_19_ + 44] = (byte) i_21_;
				}
			}
		}
		if (i > 1) {
			i_13_ += 44;
			i_14_ += 44;
			i_12_ += 44;
			i_15_ += 44;
			int i_22_ = i_15_ - i_12_;
			for (int i_23_ = i_12_ - 1; i_23_ >= i_14_; i_23_--) {
				Class38.aByteArray670[i_23_ + i_22_] = Class38.aByteArray670[i_23_];
			}
			for (int i_24_ = 1; i_24_ < i; i_24_++) {
				i_22_ = (i_14_ - i_13_) * i_24_;
				for (int i_25_ = i_13_; i_25_ < i_14_; i_25_++) {
					Class38.aByteArray670[i_25_ + i_22_] = Class38.aByteArray670[i_25_];
				}
			}
			i_15_ -= 44;
		}
		return i_15_;
	}
}
